﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Reflection;
using System.Threading;
using AlertSystem;
using AlertSystem.Dab.LK;
using LLoger;

namespace TestConsole
{
    public class Program
    {


        private static void Main()
        {

            Console.WriteLine(GetIncFileName(path: @"e:\work\TradePortal_2\TradePortal\TestConsole\bin\Release\", fileName: "A.zip"));

            Console.ReadKey();

        }

        private static string GetIncFileName(string path, string fileName)
        {
            string res = fileName;
            int i = 2;
            foreach (var file in Directory.EnumerateFiles(path))
            {
                if (Path.GetFileName(file) == fileName)
                {

                    res = Path.GetFileNameWithoutExtension(fileName) + "_" + (i++) + Path.GetExtension(fileName);
                    res = GetIncFileName(path, res);
                    break;
                }
            }

            return res;
        }
    }


}
